var setting = {
	aggiorna : function(){
		
		$.ajax({
			type : 'POST',
			data : $('#form_setting_a').serialize() , 
			url : '<?php echo base_url();?>setting/inserisci_a_db' , 
			cache : false , 
			success : function(data_resp){
				if(data_resp=="1") window.location = '<?php echo base_url();?>setting/setting_a'
				// alert(data_resp);
			}
		});
		
	}
}



$(function() {
		var availableTags = [
			"ActionScript",
			"AppleScript",
			"Asp",
			"BASIC",
			"C",
			"C++",
			"Clojure",
			"COBOL",
			"ColdFusion",
			"Erlang",
			"Fortran",
			"Groovy",
			"Haskell",
			"Java",
			"JavaScript",
			"Lisp",
			"Perl",
			"PHP",
			"Python",
			"Ruby",
			"Scala",
			"Scheme"
		];
		/*
		$( "#comune_residenza" ).autocomplete({
			source: availableTags
		});
		*/
		
		// Autocomplete comune residenza
		$("#comune_residenza").autocomplete({
		source : function(request, response){
			$.ajax({
				type : "POST" , 
				cache: false,
				url: "<?php echo base_url();?>setting/citta_autocomplete" , 
				dataType: "json" , 
				data : 'campo_search=' + request.term , 
				success: function( data ) {
					response(data);
				}
			});

		} , 
		minLength: 3 ,		
		select: function(event, ui) {
			$("#comune_residenza_id").val(ui.item.id);
		}
	});
	
	// Autocomplete comune nascita
	$("#comune_nascita").autocomplete({
		source : function(request, response){
			$.ajax({
				type : "POST" , 
				cache: false,
				url: "<?php echo base_url();?>setting/citta_autocomplete" , 
				dataType: "json" , 
				data : 'campo_search=' + request.term , 
				success: function( data ) {
					response(data);
				}
			});

		} , 
		minLength: 3 ,		
		select: function(event, ui) {
			$("#comune_nascita_id").val(ui.item.id);
		}
	});
	
	
	ricerca.init();
	
	$("#accordion").accordion({ autoHeight: false, active: 2 });
	
	$('#setting_a_butt').button();	
});

